package org.example.sys.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.sys.entity.TSysRoleMenu;
import org.example.sys.entity.dto.MenuDTO;
import org.example.sys.mapper.TSysRoleMenuMapper;
import org.example.sys.service.TSysRoleMenuService;
import org.example.core.utils.BeanConvertUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 角色目录权限表(TSysRoleMenu)表服务实现类
 * @author Calvin
 */
@Service("tSysRoleMenuService")
public class TSysRoleMenuServiceImpl extends ServiceImpl<TSysRoleMenuMapper, TSysRoleMenu> implements TSysRoleMenuService {

    @Override
    public List<MenuDTO> listMenuByUserId(Long userId, Integer menuType) {
        List<MenuDTO> menuDTOList = BeanConvertUtils.convertListTo(baseMapper.listMenuByUserId(userId, menuType),MenuDTO::new);
        return CollectionUtils.isEmpty(menuDTOList) ? null : menuDTOList;
    }

    @Override
    public List<MenuDTO> listMenuByRoleIds(List<Integer> roleIds, Integer menuType) {
        List<MenuDTO> menuDTOList = BeanConvertUtils.convertListTo(baseMapper.listMenuByRoleIds(roleIds, menuType),MenuDTO::new);
        return CollectionUtils.isEmpty(menuDTOList) ? null : menuDTOList;
    }

}

